07. Launch an Instance
Launch an Instance
In order to start the instance please run the following command to create an instance that supports the latest version of PyTorch. We recommend copy-pasting each line and editing the names and zones, as commented below.
Remember to type in your specific location code that you entered in the previous step. You may need to add a letter to the end for specificity.
export INSTANCE_NAME="my-compute-engine-instance" # Put any name here!
export IMAGE="pytorch-latest-cu91-1531880092"
export PROJECT_NAME="" # Put your Google Cloud Project name here!
export ZONE="us-west1-b" # Put zone you requested quota in: asia-east1-a, europe-west1-d or us-west1-b
gcloud compute instances create $INSTANCE_NAME \
--zone=$ZONE \
--image=$IMAGE \
--project=$PROJECT_NAME \
--image-project=deeplearning-platform-release \
--maintenance-policy=TERMINATE \
--accelerator='type=nvidia-tesla-k80,count=1' \
--metadata='install-nvidia-driver=True' \
--machine-type=n1-standard-2
Then you wait! Instance creation will take a few minutes. Keep in mind that instance will NOT be immediately available for accessing via SSH since the NVIDIA Driver is installed during the first boot. Please wait ~2 minutes after the instance is created before SSHing to it.
Note: If you try to SSH to the instance before NVIDIA Driver installation is finished, you will see a “Connection refused” error. You just have to wait for this error to resolve itself.
Shutdown
You will also have to shutdown this instance when you are not using it otherwise you risk incurring additional charges. To “stop” (i.e. shutdown) your instances, run one of the following commands:
gcloud compute instances stop $INSTANCE_NAME
Or if you want to delete instance completely:
gcloud compute instances delete $INSTANCE_NAME
Deleting is generally recommended, unless you are shortly pausing your work and will return to it in an hour or so (then, stopping is recommended).